package create.singleton.singleton_demo1;

/**
 * 饿汉式 线程安全,没有加锁效率高,类加载时就初始化浪费内存
 *
 * @author yeyangtao
 * @date 2020/5/19 17:38
 */
public class Single1 {
    private String name;
    private Integer age;

    private static Single1 instance = new Single1();

    private Single1() {
    }

    public static Single1 getInstance() {
        return instance;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
